home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / Game / Thing / CThingMap.as < prev    next >
Encoding:
Text File  |  2011-08-19  |  6.0 KB  |  215 lines

  1. package Local.Game.Thing
  2. {
  3.    import Local.Game.World.CPosition;
  4.    import Local.Game.World.Map.CMap;
  5.    import Local.Game.World.Map.Cell.CCell;
  6.    import flash.geom.Point;
  7.    
  8.    public class CThingMap extends CThingDraw
  9.    {
  10.       
  11.       public static const CURRENTCELL_CHANGED:String = "CURRENTCELL_CHANGED";
  12.       
  13.       public static const mBloatCellSearch:Number = CMap.mCellSize * 3;
  14.        
  15.       
  16.       public var mCellCurrent:CCell;
  17.       
  18.       public var mShowOnMap:Boolean;
  19.       
  20.       public var mCollide:CTCollide;
  21.       
  22.       public function CThingMap()
  23.       {
  24.          super();
  25.       }
  26.       
  27.       public function Move(param1:CPosition) : Boolean
  28.       {
  29.          if(true)
  30.          {
  31.             mPosition.x += param1.x;
  32.             mPosition.y += param1.y;
  33.          }
  34.          return MapMove();
  35.       }
  36.       
  37.       override public function Dispose() : void
  38.       {
  39.          if(mDisposed)
  40.          {
  41.             return;
  42.          }
  43.          if(mCellCurrent)
  44.          {
  45.             MapRemove();
  46.          }
  47.          super.Dispose();
  48.       }
  49.       
  50.       public function _validThing(param1:int) : Boolean
  51.       {
  52.          return mGroupID == param1 || mCollide == null || mDead ? false : true;
  53.       }
  54.       
  55.       public function MapMove() : Boolean
  56.       {
  57.          ┬º┬ºpush(mCellCurrent);
  58.          if(true)
  59.          {
  60.             ┬º┬ºpush(┬º┬ºpop().InCell(mPosition.x));
  61.             if(true)
  62.             {
  63.                if(┬º┬ºpop())
  64.                {
  65.                   return false;
  66.                }
  67.                addr28:
  68.                mCellCurrent.RemoveThing(this);
  69.                mCellCurrent = mMap.AddThing(this);
  70.                ┬º┬ºpush(true);
  71.             }
  72.             return ┬º┬ºpop();
  73.          }
  74.          ┬º┬ºgoto(addr28);
  75.       }
  76.       
  77.       public function GetAltitude(param1:Number) : Number
  78.       {
  79.          return mLandscape.GetAltitude(param1);
  80.       }
  81.       
  82.       public function GetThings_Radius(param1:Number, param2:int = 10000) : Array
  83.       {
  84.          var _loc3_:Array = null;
  85.          var _loc4_:Number = NaN;
  86.          var _loc5_:CCell = null;
  87.          var _loc6_:CThingMain = null;
  88.          _loc3_ = new Array();
  89.          _loc4_ = param1 + mBloatCellSearch;
  90.          for each(_loc5_ in mMap.GetCells(mPosition.x - _loc4_,mPosition.x + _loc4_))
  91.          {
  92.             if(true)
  93.             {
  94.                var _loc9_:int = 0;
  95.                if(true)
  96.                {
  97.                   for each(_loc6_ in _loc5_.mMapwho)
  98.                   {
  99.                      if(_loc6_._validThing(mGroupID))
  100.                      {
  101.                         if(Point.distance(mPosition,_loc6_.mPosition) <= param1)
  102.                         {
  103.                            if(_loc3_.push(_loc6_) == param2)
  104.                            {
  105.                               return _loc3_;
  106.                            }
  107.                         }
  108.                      }
  109.                   }
  110.                }
  111.             }
  112.          }
  113.          return _loc3_;
  114.       }
  115.       
  116.       public function GetPosition() : CPosition
  117.       {
  118.          return mPosition;
  119.       }
  120.       
  121.       public function GetThings_Distance(param1:Number, param2:int = 10000) : Array
  122.       {
  123.          var _loc3_:Array = null;
  124.          var _loc4_:CCell = null;
  125.          var _loc5_:CThingMain = null;
  126.          _loc3_ = new Array();
  127.          loop0:
  128.          for each(_loc4_ in mMap.GetCells(mPosition.x,mPosition.x + (param1 + mBloatCellSearch) * mOrientation))
  129.          {
  130.             if(true)
  131.             {
  132.                var _loc8_:int = 0;
  133.                var _loc9_:* = _loc4_.mMapwho;
  134.                loop1:
  135.                while(true)
  136.                {
  137.                   for each(_loc5_ in _loc9_)
  138.                   {
  139.                      if(!_loc5_._validThing(mGroupID))
  140.                      {
  141.                         if(true)
  142.                         {
  143.                         }
  144.                      }
  145.                      else if(Point.distance(mPosition,_loc5_.mPosition) > param1)
  146.                      {
  147.                         if(false)
  148.                         {
  149.                            break loop1;
  150.                         }
  151.                      }
  152.                      else if(_loc3_.push(_loc5_) == param2)
  153.                      {
  154.                         break loop1;
  155.                      }
  156.                   }
  157.                   continue loop0;
  158.                }
  159.                return _loc3_;
  160.             }
  161.          }
  162.          return _loc3_;
  163.       }
  164.       
  165.       public function GetThings_Line(param1:CPosition, param2:CPosition, param3:int = 10000) : Array
  166.       {
  167.          var _loc4_:Array = null;
  168.          var _loc5_:CCell = null;
  169.          var _loc6_:CThingMain = null;
  170.          _loc4_ = new Array();
  171.          var _loc7_:int = 0;
  172.          if(true)
  173.          {
  174.             for each(_loc5_ in param1.x > param2.x ? mMap.GetCells(param1.x + mBloatCellSearch,param2.x - mBloatCellSearch) : mMap.GetCells(param1.x - mBloatCellSearch,param2.x + mBloatCellSearch))
  175.             {
  176.                for each(_loc6_ in _loc5_.mMapwho)
  177.                {
  178.                   if(_loc6_._validThing(mGroupID))
  179.                   {
  180.                      if(_loc6_.mCollide.CollideLine(param1,param2,true))
  181.                      {
  182.                         if(_loc4_.push(_loc6_) == param3)
  183.                         {
  184.                            return _loc4_;
  185.                         }
  186.                      }
  187.                   }
  188.                }
  189.             }
  190.             return _loc4_;
  191.          }
  192.          ┬º┬ºgoto(addr31);
  193.       }
  194.       
  195.       public function MapAdd() : void
  196.       {
  197.          if(true)
  198.          {
  199.             mCellCurrent = mMap.AddThing(this);
  200.          }
  201.       }
  202.       
  203.       public function MapRemove() : void
  204.       {
  205.          mCellCurrent.RemoveThing(this);
  206.          mCellCurrent = null;
  207.       }
  208.       
  209.       public function GetDrawPosition() : Point
  210.       {
  211.          return new Point(mPosition.x - mLandscape.mDrawPosition.x,mPosition.y - mLandscape.mDrawPosition.y);
  212.       }
  213.    }
  214. }
  215.